<template>
  <div>
    <!-- 实体-->
    <div class="card-box-2">
      <!-- 标题 -->
      <div class="title-box" v-if="!item.picUrl">
        <div class="title" v-html="highlightText(item.entityName)"></div>
      </div>
      <!-- 详情 -->
      <div class="detail-box">
        <img class="image" v-if="item.picUrl" :src="item.picUrl" alt="" />
        <div class="attr-box">
          <div>
            <span class="attr">实体名称：</span>
            <span class="detail">{{ item.entityName }}</span>
          </div>
          <div>
            <span class="attr">实体类型：</span>
            <span class="detail">{{ item.ontologyName }}</span>
          </div>
          <div>
            <span class="attr">消岐标识：</span>
            <span
              class="detail"
              v-html="highlightText(item.disambiguationIdentify)"
            ></span>
          </div>
          <div>
            <span class="attr">所属图谱：</span>
            <span class="detail">{{ item.profile }}</span>
          </div>
          <div>
            <span class="attr">所属属性：</span>
            <div>
              <ul class="detail">
                <li v-for="(i, index) in item.propertyMap" :key="index">
                  {{ i.propertyName }}：{{ i.propertyValue }}
                </li>
              </ul>
            </div>
            <!-- <span class="detail">{{ item.profile }}</span> -->
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      searchKey: '',
    };
  },
  methods: {
    setData(val) {
      this.searchKey = val;
    },
    // 高亮文字
    highlightText(text) {
      return text.replace(
        new RegExp(this.searchKey, 'g'),
        `<span style="color: #FF5151">${this.searchKey}</span>`
      );
    },
  },
};
</script>

<style lang="scss" scoped>
.card-box-2 {
  width: 100%;
}
.title-box {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
  .title {
    font-size: 22px;
    color: #ffffff;
  }
}
.detail-box {
  display: flex;
  align-items: flex-start;
  font-size: 14px;
  line-height: 2;
  width: 100%;
  .attr-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    .attr {
      color: #6599ca;
      font-size: 20px;
    }
    .detail {
      color: #ffffff;
      font-size: 20px;
    }
  }
  .image {
    height: auto;
    max-width: 200px;
    margin-right: 20px;
  }
}
</style>
